package com.test.reactor.config;
import akka.actor.ActorSystem;
import com.test.reactor.utils.ActorUtils;
import com.typesafe.config.Config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;


/**
 * @author wwmxd
 * @create 2018/3/22.
 */
@Configuration
@Slf4j
@Order(value = 1)
public class InitConfiguration implements CommandLineRunner {
    @Autowired
    private ActorSystem actorSystem;
    @Override
    public void run(String... args) throws Exception {
        log.info("init ---start");
        Config config = actorSystem.settings().config().getConfig("akka").getConfig("remote")
                .getConfig("netty").getConfig("tcp");
        String hostname = config.getString("hostname").toString();
        String port = config.getString("port").toString();
        ActorUtils.localAddress = hostname + ":" + port;
        log.info("local actor address--hostname:" + hostname +" port:" +port);
    }
}